<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2016/6/8
  Time: 19:06
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="/wechat/login/modified.css">
    <jsp:include page="../public/head.jsp" flush="true" />
</head>
<body>
<jsp:include page="../public/header.jsp" flush="true" />
<section >
    <div class="my_modified">
        <form id="form" onsubmit="return false">
            <div class="row1">
                <i class="iconfont icon-phone">&#xe603;</i>
                <input type="text" id="mobile" value="" placeholder="请输入手机号" class="user-name"  data-caution="手机号不能为空">
            </div>
            <!--/row-->
            <div class="row1">
                <i class="iconfont icon">&#xe604;</i>
                <input type="text" id="code"  name="code" value="" placeholder="输入验证码" class="mycode" data-caution="请输入验证码">
                <input type="button" onclick="sendMessage(this)"  value="获取验证码" placeholder="输入验证码" class="btn-send"  >
            </div>
            <!--/row1-->

            <input type="button" value="找回密码" class="user-agree" onclick="forget()">



        </form>
<input type="hidden" value="" id="fcode">
    </div>
</section>
<!-- 尾部 -->

<script>
    function forget() {
//        var checkpwd = /^[0-9a-zA-Z]*$/g;

        if ($("#mobile").val().length == 0){
            tip("","还未输入手机号",true);
            return;
        }
        if ($("#code").val().length == 0){
            tip("","还未输入验证码",true);
            return;
        }

        var code = $("#code").val();
        var fcode = $("#fcode").val();


        if (code != fcode){
            tip("","验证码不正确",true);
            return;
        }

        window.location.href = "/beforelogin/modifyPwd.do?"+$("#form").serialize();


    }
    var countdown=60;
    function settime(obj) {
        if (countdown == 0) {
            obj.removeAttribute("disabled");
            obj.value="免费获取验证码";
            countdown = 60;
            return;
        } else {
            obj.setAttribute("disabled", true);
            obj.value="重获 " + countdown + "s";
            countdown--;
        }
        setTimeout(function() { settime(obj) }
                ,1000)
    }

    function sendMessage(obj) {
        if ($("#mobile").val().length == 0){
            tip("","还未输入手机号",true);
            return;
        }

        settime(obj);

        //向后台发送处理数据
        $.post("/mobile/user?action=findCode",{mobile:$("#mobile").val()},
                function(data){
                    if (!data.success){

                    }else {
                        tip("",data.msg,true);
                        $("#fcode").val(data.data);
                    }
                },"json");
    }
</script>
</body>
</html>
